Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat ContextProxy to improve state management #1235

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

samhvw8
Copy link
Collaborator

@samhvw8 samhvw8 commented Feb 27, 2025

  • Add ContextProxy class as a wrapper around VSCode's ExtensionContext
  • Implement batched state updates for performance optimization
  • Update ClineProvider to use ContextProxy instead of direct context access
  • Add comprehensive test coverage for ContextProxy
  • Extract SECRET_KEYS and GLOBAL_STATE_KEYS constants for better maintainability

Description

This feature will we can open multiple window (which can have different config (mode / api config))

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Introduces ContextProxy for efficient state management in ClineProvider, with batched updates and comprehensive testing.

  • Behavior:
    • Introduces ContextProxy class in contextProxy.ts to buffer state changes and secrets, committing them on request or disposal.
    • Replaces direct context access in ClineProvider.ts with ContextProxy for efficient state management.
    • Extracts SECRET_KEYS and GLOBAL_STATE_KEYS constants in globalState.ts for maintainability.
  • Testing:
    • Adds comprehensive tests for ContextProxy in contextProxy.test.ts.
    • Updates ClineProvider.test.ts to mock and test ContextProxy integration.
  • Misc:
    • Updates ClineProvider to use ContextProxy for state and secret management, ensuring proper disposal and state handling.

This description was created by Ellipsis for dec624c. It will automatically update as commits are pushed.

@samhvw8 samhvw8 requested review from mrubens and cte as code owners February 27, 2025 07:43
Copy link

changeset-bot bot commented Feb 27, 2025

⚠️ No Changeset found

Latest commit: fbb5a19

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Feb 27, 2025
@samhvw8 samhvw8 force-pushed the feat/context-proxy branch 2 times, most recently from c12aea5 to fc11d96 Compare February 28, 2025 11:55
samhvw8 added 2 commits March 3, 2025 10:47
- Add ContextProxy class as a wrapper around VSCode's ExtensionContext
- Implement batched state updates for performance optimization
- Update ClineProvider to use ContextProxy instead of direct context access
- Add comprehensive test coverage for ContextProxy
- Extract SECRET_KEYS and GLOBAL_STATE_KEYS constants for better maintainability
@samhvw8 samhvw8 force-pushed the feat/context-proxy branch from fc11d96 to fbb5a19 Compare March 3, 2025 03:47
@@ -81,6 +97,79 @@ export type GlobalStateKey =
| "unboundModelInfo"
| "modelTemperature"
| "modelMaxTokens"
| "anthropicThinking" // TODO: Rename to `modelMaxThinkingTokens`.
| "modelMaxThinkingTokens"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still have references to anthropicThinking? Maybe should leave this cleanup for another PR

// Build the apiConfiguration object combining state values and secrets
const apiConfiguration: ApiConfiguration = {
apiProvider,
apiModelId: stateValues.apiModelId,
Copy link
Collaborator

@mrubens mrubens Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way to use the globalstatekeys here so we don't need to repeat this big list? Or is it a different subset of the list?

}
}

// Called when the provider is disposing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this happen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants